package com.pattern.claims;



import com.claims.UserClaimsApply;
import com.pattern.claims.base.BaseAbstractLink;
import com.pattern.claims.base.ClaimsEnum;
import com.pattern.claims.status.*;

/**
 * Created by 峥桂 on 2017/6/9
 */
public class ClaimsLinkHelper {

    private FirstAuditLink firstAuditLink;//初审环节处理类
    private InputDataLink inputDataLink;//录入环节处理类
    private SecondAuditLink secondAuditLink;//第二次审核环节处理类
    private SettlementLink settlementLink;//理算环节处理类
    private ClosingLink closingLink;//结案环节处理类

    private BaseAbstractLink baseAbstractLink;
    public BaseAbstractLink getLinkHandlerObj(ClaimsEnum status, UserClaimsApply userClaimsApply){
        //准备对象
        buildLinkHandlerObj(status);


        if(baseAbstractLink!=null){
            baseAbstractLink.setUserClaimsApply(userClaimsApply);
            baseAbstractLink.setCurrentLinkValue(status.getValue());
            System.out.println( "\r进入"+status.getValue()+"---->理赔单信息【理赔申请 code:"+userClaimsApply.getApplycode()
                    +" ID:"+userClaimsApply.getId()+"】");
            //开始执行相应的方法
            baseAbstractLink.taskClaim();
            baseAbstractLink.taskHandler();
            baseAbstractLink.taskProblem();
            baseAbstractLink.taskFinished();
        }
        return baseAbstractLink;
    }

    private void buildLinkHandlerObj(ClaimsEnum status){
        switch (status){
            case Link_First_Audit:
                baseAbstractLink=firstAuditLink;
                break;
            case Link_Input_Data:
                baseAbstractLink= inputDataLink;
                break;
            case Link_Second_Audit:
                baseAbstractLink= secondAuditLink;
                break;
            case Link_Settlement:
                baseAbstractLink= settlementLink;
                break;
            case Link_Closing:
                baseAbstractLink= closingLink;
                break;
            default:
                baseAbstractLink=null;
        }
    }



}
